package android.activities;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.controllers.SocialController;
import android.os.Bundle;
import android.tools.ExtendedAlertDialog;
import android.tools.ImageAdapter;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Gallery;
import android.widget.RatingBar;
import android.widget.TextView;

public class SocialActivity extends Activity {
	private Gallery _gallery = null;
	private SocialController _controller = null;
	private TextView _name = null;
	private TextView _description = null;
	private TextView _step = null;
	private RatingBar _rate = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.social);

		_controller = new SocialController(this);

		_name = (TextView) findViewById(R.id.social_tx_name_value);
		_description = (TextView) findViewById(R.id.social_tx_description_value);
		_step = (TextView) findViewById(R.id.social_tx_step_value);
		_rate = (RatingBar) findViewById(R.id.social_ratingbar);

		_gallery = (Gallery) findViewById(R.id.social_gallery);
		_gallery.setAdapter(new ImageAdapter(this));

		_gallery.setOnItemClickListener(_controller);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		boolean r = false;
		switch (item.getItemId()) {
		case android.activities.R.id.menu_comment:
			ExtendedAlertDialog dialog = new ExtendedAlertDialog(1, this);

			dialog.setTitle(this.getResources().getString(
					R.string.comment_title));
			View view = ((LayoutInflater) this
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(R.layout.comment, null);

			dialog.setButton(Dialog.BUTTON_NEGATIVE, "Cancel", this._controller);
			dialog.setButton(Dialog.BUTTON_POSITIVE, "Add", this._controller);

			dialog.setView(view);
			dialog.show();
			r = true;
			break;
		case android.activities.R.id.menu_course:
			Intent intent = new Intent(this, CourseAddActivity.class);
			Bundle bundle = new Bundle();
			
			
			this.startActivity(intent.putExtras(bundle));
			r = true;
			break;
		default:
			r = super.onOptionsItemSelected(item);
			break;
		}

		return r;
	}

	public TextView get_name() {
		return _name;
	}

	public void set_name(TextView _name) {
		this._name = _name;
	}

	public TextView get_description() {
		return _description;
	}

	public void set_description(TextView _description) {
		this._description = _description;
	}

	public RatingBar get_rate() {
		return _rate;
	}

	public void set_rate(RatingBar _rate) {
		this._rate = _rate;
	}

	public TextView get_step() {
		return _step;
	}

	public void set_step(TextView _step) {
		this._step = _step;
	}
}
